//
//  NextViewController.swift
//  YDemoDelegate
//
//  Created by bruce yao on 2019/7/17.
//  Copyright © 2019 bruce yao. All rights reserved.
//

import UIKit

class NextViewController: UIViewController {
    weak var delegate: NextVCDelegate?
    
    @IBOutlet weak var textField: UITextField!
    
    override func viewWillDisappear(_ animated: Bool) {
        textField.resignFirstResponder()
        if delegate != nil {
            delegate?.nextVCTextFieldValue(value: textField.text)
        }
    }
    
    override func viewDidLoad() {
        super.viewDidLoad()

        // Do any additional setup after loading the view.
    }
    
    deinit {
        print("销毁啦")
    }
    /*
    // MARK: - Navigation

    // In a storyboard-based application, you will often want to do a little preparation before navigation
    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
        // Get the new view controller using segue.destination.
        // Pass the selected object to the new view controller.
    }
    */

}

//声明协议
@objc protocol NextVCDelegate {
    //协议方法
    func nextVCTextFieldValue(value: String?)
}
